import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import 'amfe-flexible'
import './router/rule'
import { Search, NavBar, Form, Field, Button, Image, Tabbar, TabbarItem, Icon, Tab, Tabs, Cell, CellGroup, List, PullRefresh, ActionSheet, Tag, Dialog, Popup, Row, Col, Badge, Divider, DatetimePicker } from 'vant'

Vue.use(DatetimePicker)
Vue.use(Image)
Vue.use(Tag)
Vue.use(Divider)
Vue.use(Search)
Vue.use(Badge)
Vue.use(Col)
Vue.use(Row)
Vue.use(ActionSheet)
Vue.use(List)
Vue.use(Tabbar)
Vue.use(TabbarItem)
Vue.use(Cell)
Vue.use(CellGroup)
Vue.use(PullRefresh)
Vue.use(Icon)
Vue.use(Tab)
Vue.use(Tabs)
Vue.use(Button)
Vue.use(Form)
Vue.use(Field)
Vue.use(NavBar)
Vue.use(Dialog)
Vue.use(Popup)

// 自定义命令
Vue.directive('gfocus', {
  inserted (e) {
    if (['INPUT', 'TEXTAREA'].indexOf(e.tagName) !== -1) {
      e.focus()
    } else {
      let node = e.querySelector('input')
      if (node) {
        node.focus()
        return
      }
      node = e.querySelector('textarea')
      if (node) {
        node.focus()
        return
      }
      throw new Error('请把foucs指令添加到表单项')
    }
  }
})
Vue.config.productionTip = false
new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
